import { selectDashboardData } from '@/api/home/home-api.js'

// 材料
const state = {
  list: {}
}

// 加工
const getters = {
  list2(state) {
    return state.list || {}
  }
}

// 厨师
const mutations = {
  GET_DATA(state, list) {
    state.list = list
  }
}

// 迎宾
const actions = {
  // 发请求获取首页的mock数据
  async getDashboardData({ commit }) {
    const result = await selectDashboardData()
    if (result.code === 20000) {
      commit('GET_DATA', result.data)
      return result
    } else {
      return Promise.reject('500')
    }
  }
}

// 分店
export default {
  state,
  mutations,
  actions,
  getters
}
